﻿#include "FITKAbaSectionBeam.h"
#include "FITKAbaProfile.h"
#include "FITK_Kernel/FITKCore/FITKDataRepo.h"


Interface::FITKAbaAbastractSection::FITKAbaSectionType Interface::FITKAbaSectionBeam::getSectionType()
{
    return Interface::FITKAbaAbastractSection::FITKAbaSectionType::Beam;
}

bool Interface::FITKAbaSectionBeam::copy(FITKAbstractDataObject* obj)
{
    bool ok = FITKAbaAbastractSection::copy(obj);
    if (!ok)
        return false;
    FITKAbaSectionBeam* objBeam = dynamic_cast<FITKAbaSectionBeam*>(obj);
    if (objBeam == nullptr)
        return false;
    this->m_profileId = objBeam->m_profileId;
    this->m_temperatureVariation = objBeam->m_temperatureVariation;
    return true;
}

QString Interface::FITKAbaSectionBeam::getProfileName() const
{
    FITKAbaProfile* profile = this->getProfile();
    if (profile == nullptr)
        return "";
    return profile->getDataObjectName();
}

void Interface::FITKAbaSectionBeam::setProfileId(int profileId)
{
    m_profileId = profileId;
}

void Interface::FITKAbaSectionBeam::setProfile(FITKAbaProfile* profile)
{
    if (profile == nullptr)
        return;
    m_profileId = profile->getDataObjectID();
}

int Interface::FITKAbaSectionBeam::getProfileId() const
{
    return m_profileId;
}

Interface::FITKAbaProfile* Interface::FITKAbaSectionBeam::getProfile() const
{
    if (m_profileId < 0)
        return nullptr;
    return Core::FITKDataRepo::getInstance()->getTDataByID<FITKAbaProfile>(m_profileId);
}

QString Interface::FITKAbaSectionBeam::getTypeString()
{
    return "Beam, Constant";
}

Interface::FITKAbaAbastractSection::TemperatureVariation Interface::FITKAbaSectionBeam::getTemperatureVariation() const
{
    return m_temperatureVariation;
}

void Interface::FITKAbaSectionBeam::setTemperatureVariation(FITKAbaAbastractSection::TemperatureVariation tv)
{
    m_temperatureVariation = tv;
}

